[!net:proxy.golang.org] skip

env GO111MODULE=on
env GOSUMDB=
env GOPATH=$WORK/gopath1

# With a file-based proxy with an empty checksum directory,
# downloading a new module should fail, even if a subsequent
# proxy contains a more complete mirror of the sum database.
#
# TODO(bcmills): The error message here is a bit redundant.
# It comes from the sumweb package, which isn't yet producing structured errors.
[GOOS:windows] env GOPROXY=file:///$WORK/sumproxy,https://proxy.golang.org
[!GOOS:windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org
! go get golang.org/x/text@v0.3.2
stderr '^go: golang.org/x/text@v0.3.2: verifying module: golang.org/x/text@v0.3.2: reading file://.*/sumdb/sum.golang.org/lookup/golang.org/x/text@v0.3.2: (no such file or directory|.*cannot find the path specified.*)'

# If the proxy does not claim to support the database,
# checksum verification should fall through to the next proxy,
# and downloading should succeed.
[GOOS:windows] env GOPROXY=file:///$WORK/emptyproxy,https://proxy.golang.org
[!GOOS:windows] env GOPROXY=file://$WORK/emptyproxy,https://proxy.golang.org
go get golang.org/x/text@v0.3.2

# After a successful sumdb lookup, the lookup can be repeated
# using the download cache as a proxy.
cp supported $GOPATH/pkg/mod/cache/download/sumdb/sum.golang.org/supported
[GOOS:windows] env GOPROXY=file:///$WORK/gopath1/pkg/mod/cache/download,file:///$WORK/sumproxy
[!GOOS:windows] env GOPROXY=file://$WORK/gopath1/pkg/mod/cache/download,file://$WORK/sumproxy
env GOPATH=$WORK/gopath2
rm go.sum
go get -x -v golang.org/x/text@v0.3.2

# Once the checksum is present in the go.sum file,
# an empty file-based sumdb can be used in conjunction with
# a fallback module mirror.
grep golang.org/x/text go.sum
env GOPATH=$WORK/gopath3
[GOOS:windows] env GOPROXY=file:///$WORK/sumproxy
[!GOOS:windows] env GOPROXY=file://$WORK/sumproxy
! go get golang.org/x/text@v0.3.2
[GOOS:windows] env GOPROXY=file:///$WORK/sumproxy,https://proxy.golang.org
[!GOOS:windows] env GOPROXY=file://$WORK/sumproxy,https://proxy.golang.org
go get golang.org/x/text@v0.3.2

-- supported --

-- go.mod --
module example.com
go 1.13
-- $WORK/emptyproxy/README.md --
This proxy contains no modules.
-- $WORK/sumproxy/README.md --
This proxy contains no modules.
-- $WORK/sumproxy/sumdb/sum.golang.org/supported --
This proxy blocks checksum downloads from sum.golang.org.
